#
# 主界面
# .py
#
import sys
from PyQt5.QtWidgets import qApp,QWidget, QMessageBox, QApplication, QDesktopWidget, QPushButton, QLabel
from PyQt5.QtGui import QFont,QIcon
from PyQt5.QtCore import QCoreApplication,Qt
from jianchahao import Example


class window(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        btn = QPushButton('测 算', self)
        btn.setToolTip('<b>开始</b>测算')
        btn.setFont(QFont('SansSerif', 20))
        btn.resize(200, 60)
        btn.move(200, 300)
        btn.clicked.connect(self.on_pushButton_clicked)

        lbl1 = QLabel('欢迎使用玉环县人民医院\n\nTW3骨龄法软件', self)
        lbl1.setFont(QFont('SansSerif', 25))
        lbl1.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        lbl1.move(60, 70)
        lbl2 = QLabel('版本0.1 制作人：苏维杰', self)
        lbl2.setFont(QFont('SansSerif', 14))
        lbl2.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        lbl2.move(130, 450)

        self.setFixedSize(800, 800)
        self.setWindowTitle('玉环县人民医院 骨龄测算 0.10')
        self.setWindowIcon(QIcon("images/myicon.png"))
        self.center()
        self.show()

    # 点击测量按钮后引入子页面，并隐藏自己页面
    def on_pushButton_clicked(self):
        self.dlg = Example()
        self.dlg.show()
        self.window().hide()


    def center(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())
#
    def closeEvent(self, QCloseEvent):
        reply = QMessageBox.question(self, '退出？', "确定退出吗?",
                                     QMessageBox.Yes, QMessageBox.No)
        if reply == QMessageBox.Yes:
            QCloseEvent.accept()
            qApp.quit
        else:
            QCloseEvent.ignore()
if __name__ == '__main__':
    app = QApplication(sys.argv)
    st = window()
    sys.exit(app.exec_())
